package android.meetingatsb.widget

import android.app.Fragment
import android.meetingatsb.R
import android.meetingatsb.common.FontAwesome
import android.meetingatsb.common.User
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.RatingBar
import android.widget.TextView

class UserInfoFragment : Fragment() {
    lateinit var icon: ImageView
    lateinit var name: TextView
    lateinit var gender: TextView
    lateinit var age: TextView
    lateinit var group: TextView

    lateinit var ratingNum: TextView
    lateinit var rating: RatingBar

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View {
        val view = inflater!!.inflate(R.layout.fragment_user_info, container, false)
        bindWidgets(view)
        setData()
        return view
    }

    private fun bindWidgets(view: View) {
        icon = view.findViewById(R.id.user_icon)

        name = view.findViewById(R.id.user_name)

        gender = view.findViewById(R.id.user_gender)
        age = view.findViewById(R.id.user_age)
        group = view.findViewById(R.id.user_group)

        ratingNum = view.findViewById(R.id.user_rating_num)
        rating = view.findViewById(R.id.user_rating)
    }

    private fun setData() {
        val user = arguments.get("user") as User

        //icon.src = matchUser.icon

        name.text = user.name

        gender.text = user.gender
        age.text = user.age.toString()
        group.text = user.group

        ratingNum.text = user.rating.toString()
        rating.rating = user.rating

    }
}